﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Vehicle.Web.Pages
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Post_Main.aspx.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-09-03  Created by 孙成杰 V1.00.0000
    /// 功能说明：查看公告页面类
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public partial class Post_Main : Vehicle.Web.Component.PageBase
    {
        #region ---基本变量实例化---
        BLL.Post b_Post = new Vehicle.BLL.Post();//实例化Post逻辑层变量
        Model.ComponentsInfo m_ComponentsInfo = new Vehicle.Model.ComponentsInfo();//实例化通用实体层变量
        public string onshow;//定义没有数据时页面的显示内容
        #endregion

        #region ---基本操作---
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RepeaterBind();
            }
        }
        /// <summary>
        /// 分页控件分页事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            RepeaterBind();
        }

        /// <summary>
        /// 通过时间和标题查询分页控件和Repeater数据绑定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Select_P_Time_Click(object sender, EventArgs e)
        {
            RepeaterBind();
        }
        /// <summary>
        /// 分页控件和Repeater数据绑定
        /// </summary>
        public void RepeaterBind()
        {
            this.Anp_Page.RecordCount = b_Post.GetAllSearchCount(new Model.ComponentsInfo("Post", "1", "1", "P_Time", "P_Title", this.txt_P_Title.Text.Trim(), Common.TextHelper.StringToDateTime((this.Gmdp_Start.DateString)), Common.TextHelper.StringToDateTime((this.Gmdp_End.DateString)), "P_ID"));//更具公告标题进行分页控件的绑定
            m_ComponentsInfo.startIndex = Anp_Page.StartRecordIndex;//分页控件起始页
            m_ComponentsInfo.endIndex = Anp_Page.EndRecordIndex;//分页控件当前页的结束索引
            if (txt_P_Title.Text != "")//判断标题不为空
            {
                m_ComponentsInfo.Title = "P_Title";//数据库公告标题字段
                m_ComponentsInfo.TCount = this.txt_P_Title.Text.Trim();//公告标题匹配结果
            }
            if (Gmdp_Start.DateString != "")//判断起始日期不为空
            {
                m_ComponentsInfo.StartTime = Common.TextHelper.StringToDateTime(this.Gmdp_Start.DateString);//查询条件起始日期
            }
            if (Gmdp_End.DateString != "")//判断结束日期不为空
            {
                m_ComponentsInfo.EndTime = Common.TextHelper.StringToDateTime(this.Gmdp_Start.DateString);//查询条件结束日期
            }

            b_Post.RepeaterBindSearch(Rept, m_ComponentsInfo);//绑定Repeater控件

            if (Rept.Items.Count == 0)//判断没有数据时页面的显示内容
            {
                onshow = "当前页面无数据";
            }
            else
            {
                onshow = "";
            }

        }
        #endregion


    }
}
